home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / Windows / Interfaces / QD3DSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-03  |  10.2 KB  |  310 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DSet.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:     Set types and routines                                     **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1995 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DSet_h
  15. #define QD3DSet_h
  16.  
  17. #if PRAGMA_ONCE
  18.     #pragma once
  19. #endif
  20.  
  21. #if defined(THINK_C) || defined(__SC__)
  22.     #pragma options(!pack_enums, !align_arrays)
  23.     #pragma SC options align=power
  24. #elif defined(__MWERKS__)
  25.     #pragma enumsalwaysint on
  26.     #pragma align_array_members off
  27.     #pragma options align=native
  28. #elif defined(__PPCC__)
  29.     #pragma options align=power
  30. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=int
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif    /* __cplusplus */
  37.  
  38.  
  39. /******************************************************************************
  40.  **                                                                             **
  41.  **                                Set Routines                                 **
  42.  **                                                                             **
  43.  *****************************************************************************/
  44.  
  45. QD3D_EXPORT TQ3SetObject Q3Set_New(
  46.     void);
  47.  
  48. QD3D_EXPORT TQ3ObjectType Q3Set_GetType(
  49.     TQ3SetObject        set);
  50.  
  51. QD3D_EXPORT TQ3Status Q3Set_Add(
  52.     TQ3SetObject         set, 
  53.     TQ3ElementType        type,
  54.     const void             *data);
  55.  
  56. QD3D_EXPORT TQ3Status Q3Set_Get(
  57.     TQ3SetObject         set,
  58.     TQ3ElementType        type,
  59.     void                *data);
  60.  
  61. QD3D_EXPORT TQ3Boolean Q3Set_Contains(
  62.     TQ3SetObject         set,
  63.     TQ3ElementType        type);
  64.  
  65. QD3D_EXPORT TQ3Status Q3Set_Clear(
  66.     TQ3SetObject         set, 
  67.     TQ3ElementType        type);
  68.  
  69. QD3D_EXPORT TQ3Status Q3Set_Empty(
  70.     TQ3SetObject         target);
  71.  
  72. /*
  73.  *  Iterating through all elements in a set
  74.  *
  75.  *  Pass in kQ3ElementTypeNone to get first type
  76.  *  kQ3ElementTypeNone is returned when end of list is reached
  77.  */
  78. QD3D_EXPORT TQ3Status Q3Set_GetNextElementType(
  79.     TQ3SetObject         set,
  80.     TQ3ElementType        *type);        
  81.  
  82.  
  83. /******************************************************************************
  84.  **                                                                             **
  85.  **                                Attribute Types                                 **
  86.  **                                                                             **
  87.  *****************************************************************************/
  88.  
  89. /* 
  90.  *    For the data types listed below, pass in a pointer to it in the _Add 
  91.  *    and _Get calls.
  92.  *
  93.  *    For surface shader attributes, reference counts are incremented on 
  94.  *    the _Add and _Get 
  95.  */
  96.  
  97. typedef enum TQ3AttributeTypes {                /* Data Type                */
  98.     kQ3AttributeTypeNone                =  0,    /* ---------                */
  99.     kQ3AttributeTypeSurfaceUV            =  1,    /* TQ3Param2D                */ 
  100.     kQ3AttributeTypeShadingUV            =  2,    /* TQ3Param2D                 */
  101.     kQ3AttributeTypeNormal                =  3,    /* TQ3Vector3D                 */
  102.     kQ3AttributeTypeAmbientCoefficient    =  4,    /* float                     */
  103.     kQ3AttributeTypeDiffuseColor        =  5,    /* TQ3ColorRGB                */
  104.     kQ3AttributeTypeSpecularColor        =  6,    /* TQ3ColorRGB                */
  105.     kQ3AttributeTypeSpecularControl        =  7,    /* float                    */
  106.     kQ3AttributeTypeTransparencyColor    =  8,    /* TQ3ColorRGB                */
  107.     kQ3AttributeTypeSurfaceTangent        =  9,    /* TQ3Tangent2D              */
  108.     kQ3AttributeTypeHighlightState        = 10,    /* TQ3Switch                 */
  109.     kQ3AttributeTypeSurfaceShader        = 11,    /* TQ3SurfaceShaderObject    */
  110.     kQ3AttributeTypeNumTypes
  111. } TQ3AttributeTypes;
  112.  
  113. typedef TQ3ElementType TQ3AttributeType;
  114.  
  115.  
  116. /******************************************************************************
  117.  **                                                                             **
  118.  **                                Attribute Drawing                             **
  119.  **                                                                             **
  120.  *****************************************************************************/
  121.  
  122. QD3D_EXPORT TQ3Status Q3Attribute_Submit(
  123.     TQ3AttributeType        attributeType,
  124.     const void                *data,
  125.     TQ3ViewObject            view);
  126.  
  127.  
  128. /******************************************************************************
  129.  **                                                                             **
  130.  **                            AttributeSet Routines                             **
  131.  **                                                                             **
  132.  *****************************************************************************/
  133.  
  134. QD3D_EXPORT TQ3AttributeSet Q3AttributeSet_New(
  135.     void);
  136.  
  137. QD3D_EXPORT TQ3Status Q3AttributeSet_Add(
  138.     TQ3AttributeSet         attributeSet, 
  139.     TQ3AttributeType        type,
  140.     const void                 *data);
  141.  
  142. QD3D_EXPORT TQ3Boolean Q3AttributeSet_Contains(
  143.     TQ3AttributeSet            attributeSet,
  144.     TQ3AttributeType        attributeType);
  145.  
  146. QD3D_EXPORT TQ3Status Q3AttributeSet_Get(
  147.     TQ3AttributeSet         attributeSet,
  148.     TQ3AttributeType        type,
  149.     void                    *data);
  150.  
  151. QD3D_EXPORT TQ3Status Q3AttributeSet_Clear(
  152.     TQ3AttributeSet         attributeSet,
  153.     TQ3AttributeType        type);
  154.  
  155. QD3D_EXPORT TQ3Status Q3AttributeSet_Empty(
  156.     TQ3AttributeSet         target);
  157.  
  158. /*
  159.  * Q3AttributeSet_GetNextAttributeType
  160.  *
  161.  * Pass in kQ3AttributeTypeNone to get first type
  162.  * kQ3AttributeTypeNone is returned when end of list is reached
  163.  */
  164. QD3D_EXPORT TQ3Status Q3AttributeSet_GetNextAttributeType(
  165.     TQ3AttributeSet         source,
  166.     TQ3AttributeType        *type);        
  167.  
  168. QD3D_EXPORT TQ3Status Q3AttributeSet_Submit(
  169.     TQ3AttributeSet            attributeSet, 
  170.     TQ3ViewObject            view);
  171.  
  172. /*
  173.  * Inherit from parent->child into result
  174.  *    Result attributes are:
  175.  *        all child attributes + all parent attributes NOT in the child
  176.  */
  177. QD3D_EXPORT TQ3Status Q3AttributeSet_Inherit(
  178.     TQ3AttributeSet            parent, 
  179.     TQ3AttributeSet            child, 
  180.     TQ3AttributeSet            result);
  181.  
  182.  
  183. /******************************************************************************
  184.  **                                                                             **
  185.  **                            Custom Element Registration                         **
  186.  **                                                                             **
  187.  *****************************************************************************/
  188.  
  189. /*
  190.  * Element Methods - 
  191.  *
  192.  *         When you create a custom element, you control what structures are 
  193.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  194.  *        take one type of argument, store your element internally in some 
  195.  *        abstract data type, and have the Q3Set_Get call take a different 
  196.  *        argument.
  197.  *
  198.  *        For example:
  199.  *            
  200.  *        There are four calls which at some point will copy an element:
  201.  *
  202.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  203.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  204.  *        Q3Object_Duplicate (all elements are copied internally)
  205.  *        Q3AttributeSet_Inherit (all elements are copied internally)
  206.  *
  207.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  208.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  209.  *            - CopyReplace is replacing an existing element.
  210.  *
  211.  *         CopyGet is called during the "_Get" call.
  212.  *
  213.  *         CopyDuplicate is called to duplicate an element's internal structure.
  214.  *
  215.  * Attributes Methods - 
  216.  *
  217.  *        For copying data while Inheriting. Element methods are used
  218.  *        at all other times.
  219.  *    
  220.  *         CopyInherit is called to duplicate an element's internal structure 
  221.  *            during inheritance. You should make this as fast as possible.
  222.  *            (for example, if your custom element contains objects, you
  223.  *             should do a Q3Shared_GetReference instead of a Q3Object_Duplicate)
  224.  *            
  225.  *        The ElementDelete method will be called for all of your elements copied 
  226.  *        around via CopyAdd, CopyReplace, CopyDuplicate, and CopyInherit.
  227.  *        If CopyGet allocates any memory in it's destination, it is up to the app 
  228.  *        to delete it on its side.
  229.  */
  230.  
  231. #define kQ3MethodTypeElementCopyAdd            Q3_METHOD_TYPE('e','c','p','a')
  232. #define kQ3MethodTypeElementCopyReplace        Q3_METHOD_TYPE('e','c','p','r')
  233. #define kQ3MethodTypeElementCopyGet            Q3_METHOD_TYPE('e','c','p','g')
  234. #define kQ3MethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  235. #define kQ3MethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  236.  
  237. typedef TQ3Status (*TQ3ElementCopyAddMethod)(    
  238.     const void            *fromAPIElement,            /* element from _Add API call */
  239.     void                *toInternalElement);        /* to new QD3D internal element */
  240.  
  241. typedef TQ3Status (*TQ3ElementCopyReplaceMethod)(
  242.     const void            *fromAPIElement,            /* element from _Add API call */
  243.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  244.  
  245. typedef TQ3Status (*TQ3ElementCopyGetMethod)(
  246.     const void            *fromInternalElement,        /* from QD3D internal element */
  247.     void                *toAPIElement);                /* to _Get API call */
  248.  
  249. typedef TQ3Status (*TQ3ElementCopyDuplicateMethod)(
  250.     const void            *fromInternalElement,        /* from QD3D internal element */
  251.     void                *toInternalElement);        /* to new QD3D internal element */
  252.  
  253. typedef TQ3Status (*TQ3ElementDeleteMethod)(    
  254.     void                *internalElement);
  255.  
  256. QD3D_EXPORT TQ3ObjectClass Q3ElementClass_Register(
  257.      TQ3ElementType        elementType,
  258.     const char            *name,
  259.     unsigned long        sizeOfElement,
  260.     TQ3MetaHandler        metaHandler);
  261.  
  262. QD3D_EXPORT TQ3Status Q3ElementType_GetElementSize(
  263.      TQ3ElementType        elementType,
  264.     unsigned long        *sizeOfElement);
  265.  
  266.  
  267. /******************************************************************************
  268.  **                                                                             **
  269.  **                        Custom Attribute Registration                         **
  270.  **                                                                             **
  271.  *****************************************************************************/
  272.  
  273. #define kQ3MethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  274. typedef TQ3Boolean        TQ3AttributeInheritMethod;
  275. /* return kQ3True or kQ3False in your metahandler */
  276.  
  277. #define kQ3MethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  278. typedef TQ3Status (*TQ3AttributeCopyInheritMethod)(
  279.     const void            *fromInternalAttribute,        /* from QD3D internal element */
  280.     void                *toInternalAttribute);        /* to new QD3D internal element */
  281.  
  282. QD3D_EXPORT TQ3ObjectClass Q3AttributeClass_Register(
  283.     TQ3AttributeType    attributeType,
  284.     const char            *creatorName,
  285.     unsigned long        sizeOfElement,
  286.     TQ3MetaHandler        metaHandler);
  287.  
  288. /*
  289.     Version 1.1
  290.  */
  291. #define kQ3MethodTypeAttributeDefault        Q3_METHOD_TYPE('a','s','d','f')
  292. typedef TQ3Status (*TQ3AttributeDefaultMethod)(    
  293.     void                *internalElement);
  294.  
  295. #define kQ3MethodTypeAttributeIsDefault        Q3_METHOD_TYPE('a','i','d','f')
  296. typedef TQ3Boolean (*TQ3AttributeIsDefaultMethod)(    
  297.     void                *internalElement);
  298.  
  299. #ifdef __cplusplus
  300. }
  301. #endif    /* __cplusplus */
  302.  
  303. #if defined(__MWERKS__)
  304.     #pragma enumsalwaysint reset
  305. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  306.     #pragma options enum=reset
  307. #endif
  308.  
  309. #endif /*  QD3DSet_h */
  310.